import 'dart:convert';

import 'package:yuan_hang_app/bean/model_entity.dart';
import 'package:yuan_hang_app/widget/label_item.dart';



class DictEntity {
  int codeId;
  int type;
 // String typeName;
  String codeCnDesc;
 // String? codeEnDesc;

  DictEntity({
    required this.codeId,
    required this.type,
   // required this.typeName,
    required this.codeCnDesc,
  //  this.codeEnDesc,
  });

  factory DictEntity.fromJson(Map<String, dynamic> json) => DictEntity(
        codeId: json["codeId"],
        type: json["type"],
       // typeName: json["typeName"],
        codeCnDesc: json["codeCnDesc"],
      //  codeEnDesc: json["codeEnDesc"],
      );

  Map<String, dynamic> toJson() => {
        "codeId": codeId,
        "type": type,
       // "typeName": typeName,
        "codeCnDesc": codeCnDesc,
       // "codeEnDesc": codeEnDesc,
      };



  static List<Map> exchangeLabelList(List<DictEntity> entitys) {
    List<Map> list = [];
    for (DictEntity entity in entitys) {
      list.add({"label": entity.codeCnDesc, "value": entity.codeId.toString()});
    }
    return list;
  }


  DictEntity dictEntityFromJson(String str) =>
      DictEntity.fromJson(json.decode(str));

  String dictEntityToJson(DictEntity data) => json.encode(data.toJson());



}
